package com.codi.api.controller;

import com.codi.bus.core.service.impl.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author: zengxl
 * @Description:
 * @Date: 2018/4/16 14:38
 */
@RestController
public class PortfolioDividentController {

    @Autowired
    private PortfolioDividentServie portfolioDividentServie;
    @Autowired
    private LocaldataTradeOrderService localdataTradeOrderService;
    @Autowired
    private LocaldataShareDetailService localdataShareDetailService;
    @Autowired
    private LocaldataProfitService localdataProfitService;
    @Autowired
    private LocaldataUserShareService localdataUserShareService;
    @Autowired
    private BusinessIncomeService businessIncomeService;
    @GetMapping("/portfolioDivident")
    public String dividentTypeQuery(){
        portfolioDividentServie.dividentTypeQuery();
        return "aaa";
    }
    @GetMapping("/portfolioDividentInit")
    public String dividentTypeQueryInit(){
        portfolioDividentServie.init();
        return "init";
    }
    @GetMapping("/updateOrder")
    public String updateOrder(){
        localdataTradeOrderService.updateOrder(true);
        return "updateOrder";
    }
    @GetMapping("/tradeOrderInit")
    public String tradeOrderInit(){
        localdataTradeOrderService.init();
        return "tradeOrderInit";
    }
    @GetMapping("/addApplyOrder")
    public String addApplyOrder(@RequestParam String allotNo, @RequestParam boolean isPortfolio, @RequestParam String tradeAcco, String clientId) {
        localdataTradeOrderService.addApplyOrder(3165, allotNo, 0, "APP", tradeAcco, clientId);
        return "addApplyOrder";
    }

    @GetMapping("/localdataShareDetailInit")
    public String localdataShareDetailInit(){
        localdataShareDetailService.init(new Date());
        return "localdataShareDetailInit";
    }
    @GetMapping("/localdataShareInit")
    public String localdataShareInit(){
        localdataUserShareService.init();
        return "localdataShareInit";
    }
    @GetMapping("/execProfit")
    public String execProfit() throws Exception {
        localdataProfitService.execProfit();
        return "execProfit";
    }
    @GetMapping("/queryTradeOrder")
    public List<Map<String, Object>> queryTradeOrder(@RequestParam String alltNo, @RequestParam int allotNoType){
        return localdataTradeOrderService.getTradeOrder(alltNo,allotNoType);
    }

    @GetMapping("/execUserShare")
    public String execUserShare(@RequestParam String clientId){
        localdataUserShareService.execUserShare(clientId);
        return "execUserShare";
    }
    @GetMapping("/businessIncomeExec")
    public String businessIncomeExec(){
        businessIncomeService.exec();
        return "businessIncomeExec";
    }
}
